﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Xml;
using System.Xml.Schema;

namespace TV_Organizer.TVRage
{
    /// <summary>
    /// Class returned by TVRage when searching a show by name
    /// </summary>
    [XmlType(AnonymousType = true)]
    [XmlRoot(ElementName = "Results", Namespace = "", IsNullable = false)]
    [Serializable]
    public class SearchResult
    {
        [XmlElement("show", Form = XmlSchemaForm.Unqualified)]
        public SearchResultShow[] Shows { get; set; }
    }

    [XmlType(AnonymousType = true)]
    [XmlRoot(ElementName = "show", Namespace = "", IsNullable = false)]
    [Serializable]
    public class SearchResultShow
    {
        [Obsolete("For serialization purposes only", true)]
        public SearchResultShow()
        {
        }

        [XmlElement("showid")]
        public string TVRageId { get; set; }
        [XmlElement("name")]
        public string Name { get; set; }
        [XmlElement("seasons")]
        public int NumberOfSeasons { get; set; }

        [XmlAnyAttribute]
        public XmlAttribute[] AnyAttributes;

        [XmlAnyElement]
        public XmlElement[] AnyElements;

        public TVRageShow ToTVRageShow()
        {
            return new TVRageShow(this.TVRageId, this.Name);
        }
    }
}
